﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CTTool.Web.Models
{
    public class ZTreeNode
    {
        public int id { get; set; }
        public int pId { get; set; }
        private string m_name;
        public string name
        {
            get
            {
                if (m_name != null && m_name.Contains(this.extention))
                {
                    return m_name;
                }
                return m_name + this.extention;
            }
            set
            {
                m_name = value;
            }
        }
        public string md5Key { get; set; }
        public string originName { get; set; }
        public bool isParent { get; set; }
        public bool open { get; set; }
        public bool nocheck { get; set; }
        public bool @checked { get; set; }
        public List<ZTreeNode> children { get; set; }
        private string m_extention;
        public string extention
        {
            get
            {
                if (m_extention == null)
                {
                    return string.Empty;
                }
                return m_extention;
            }
            set
            {
                m_extention = value;
            }
        }
        public string dataJson { get; set; }
        public ZTreeNode()
        {
            this.extention = string.Empty;
            this.children = new List<ZTreeNode>();
        }


        public void CreateFileNode()
        {
            this.children.Clear();

            ZTreeNode hFileNode = new ZTreeNode();
            hFileNode.originName = this.originName;
            hFileNode.name = this.name;
            hFileNode.extention = ".h";
            hFileNode.nocheck = true;
            hFileNode.pId = this.id;
            hFileNode.md5Key = this.md5Key;
            this.children.Add(hFileNode);

            ZTreeNode mFileNode = new ZTreeNode();
            mFileNode.originName = this.originName;
            mFileNode.name = this.name;
            mFileNode.extention = ".m";
            mFileNode.nocheck = true;
            mFileNode.pId = this.id;
            mFileNode.md5Key = this.md5Key;
            this.children.Add(mFileNode);
        }
    }
}